#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QSqlQueryModel>
#include <QSqlTableModel>
#include "ui_mainwindow.h"
#include "customsqlmodel.h"
#include "dbpage.h"

class MainWindow : public QMainWindow, public Ui::MainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    //~MainWindow();

private slots:
    void on_actionAbout_triggered();
    void on_actionQuit_triggered();
    void tableClicked(int);
    void tableResized( int logicalIndex, int oldSize, int newSize );
    void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
    void searchFirst();
    void searchPrevious();
    void searchNext();
    void searchLast();
    void add();

private:
    void adjustTableSize();
    DbPage *db;
    QString orderBySql;
    QSqlQueryModel *model;
    void setResults();
    void search(int page);
    void createToolbar();
    QTime time;
    QAction *firstAct;
    QAction *previousAct;
    QAction *nextAct;
    QAction *lastAct;
    QAction *searchAct;
    QAction *addAct;
    QLineEdit *searchText;
    QLabel *lblResults;
    QSqlTableModel* formatModel(QSqlQueryModel* sqlModel);


};

#endif // MAINWINDOW_H
